﻿Imports System.Data.SqlClient
Public Class GuestAdd

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        cmd.Parameters("@GuestNo") = Me.TextBox1.Text
        cmd.Parameters("@GuestName") = Me.TextBox2.Text
        cmd.Parameters("@GuestDob") = Me.DateTimePicker1.Value
        cmd.Parameters("@GuestAddress") = Me.TextBox3.Text
        cmd.Parameters("@GuestPhone") = Me.TextBox4.Text
        If Me.TextBox5.Text = "" Then
            cmd.ExecuteNonQuery("INSERT INTO Guest VALUES(@GuestNo,@GuestName,@GuestDob,@GuestAddress,@GuestPhone,1);")
        Else
            cmd.Parameters("@GuestId") = TextBox5.Text
            cmd.ExecuteNonQuery("UPDATE Guest SET GuestName=@GuestName,GuestDob=@GuestDob,GuestAddress=@GuestAddress,GuestPhone=@GuestPhone WHERE GuestId=@GuestId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class